<table class="tvisible" align="center" width="124" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>
<?php // Categories list dymanic
echo "<ul id=\"catlist\">\n";
echo "<li class=\"open\"><a class=\"cat_0_expanded\" href=\"#\">All</a>\n<ul>\n";
echo "<li>:: <a class=\"catminor\" href=\"list.php?cat=All\">All Categories</a></li>\n";
$catfile = "categories.txt";
if(file_exists($catfile)) {
	$catary = file($catfile);
	$lastmajor = "xxnone"; 
	for($i=0; $i<count($catary); $i++) {
		$cdisplist = rtrim($catary[$i]);
		$cmachlist = rawurlencode($cdisplist);
		$cdisp2list = explode("::", htmlspecialchars($cdisplist));
		$cmach2list = explode("%3A%3A", $cmachlist);
		$majorlink = "<a class=\"cat_0_expanded\" href=\"#\">" . $cdisp2list[0] . "</a>";
		$minorlink = "<li>:: <a class=\"catminor\" href=\"list.php?cat=" . $cmach2list[0] . "%3A%3A" . $cmach2list[1] . "\">" . $cdisp2list[1] . "</a></li>\n";
		if($cmach2list[0] != $lastmajor) {
			$lastmajor = $cmach2list[0];
			echo "</ul></li>\n<li class=\"open\">" . $majorlink . "\n<ul>\n"; // Added for major categories
			echo $minorlink; // Added for the first subcategory
		}
		else {
			echo $minorlink; // Added for all the next subcategories
		}
	}
}
echo "</ul></li>\n</ul>\n"; // Added after the last subcategory in the end of the list
?>
</td>
</tr>
</table>